﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using YahooFinance;

namespace StockDisplay
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// Default constructor
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Fired when a news item is double clicked for viewing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NewsItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ListBox listbox = e.Source as ListBox;
            if (listbox == null) return;
            NewsItem item = listbox.SelectedItem as NewsItem;
            if (item == null) return;
            NewsWindow dlg = new NewsWindow();
            dlg.Owner = this;
            dlg.Title = item.DisplayHeadline;
            dlg.Browser1.Navigate(item.Url);
            dlg.ShowDialog();
        }
    }
}
